﻿
using EnumDefine;
using NUnit.Framework;
using System.Collections.Generic;
using System.IO;
using UnityEngine;

/// <summary>
/// 关卡任务
/// </summary>
public class QuestInfo
{
    [Header("任务类型")]
    public QuestType m_nType; // 
    [Header("任务范围")]
    public QuestOp m_nOp;
    [Header("任务参数值")]
    public int m_nValue;
    [Header("任务参数当前")]
    public int m_nCurValue;

    [Header("奖励类型")]
    public int m_nAwardType;
    [Header("奖励数量")]
    public int m_nAwardValue;

    public void Save(BinaryWriter bw)
    {
        bw.Write( (int)m_nType );
        bw.Write((int)m_nOp);
        bw.Write((int)m_nValue );
        bw.Write ((int)m_nCurValue );
        bw.Write((int)m_nAwardType );
        bw.Write((int)m_nAwardValue);
    }
    public void Load(BinaryReader br)
    {
        m_nType = (QuestType)br.ReadInt32();
        m_nOp = (QuestOp )br.ReadInt32();
        m_nValue = br.ReadInt32();
        m_nCurValue = br.ReadInt32();
        m_nAwardType = br.ReadInt32();
        m_nAwardValue = br.ReadInt32();
    }

}
/// <summary>
/// 关卡任务组
/// </summary>
public class StageQuest
{
    public int m_StageID; // 所在关
    public List<QuestInfo> m_Quests = new List<QuestInfo> ();

    /// <summary>
    /// 创建随机任务
    /// </summary>
    /// <returns></returns>
    QuestInfo CreateQuest()
    {
        return null;
    }

    public void Save( BinaryWriter bw  )
    {
        bw.Write ( m_StageID );
        bw.Write ( m_Quests.Count );
        for (int i = 0; i < m_Quests.Count; i++)
        {
            m_Quests[i].Save( bw ); 
        }
    }
    public void Load( BinaryReader br)
    {
        m_StageID = br.ReadInt32();
        int num = br.ReadInt32();
        m_Quests.Clear();
        for (int i = 0; i < num; i++)
        {
            QuestInfo info = new QuestInfo ();  
            info.Load(br);
            m_Quests.Add(info);
        }
    }

}
